package cn.ffcs.uec.reportParameter.dao.impl;


import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.common.util.PermissionUtil;
import cn.ffcs.uom.common.vo.PageInfo;
import cn.ffcs.uec.reportParameter.dao.AllStaffZaiZhiDao;
import cn.ffcs.uec.reportParameter.model.VAllStaffZaiZhi;
import cn.ffcs.uec.reportParameter.model.VSexCount;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
@Repository("allStaffZaiZhiDao")
@Transactional
public class AllStaffZaiZhiDaoImpl extends BaseDaoImpl implements AllStaffZaiZhiDao {
	@Override
	public PageInfo queryPageInfo(VAllStaffZaiZhi uecOutStaffInfo,int current, int pageSize) {
			String orgName = PermissionUtil.getManagerOrg();
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM VIEW_ALL_STAFF_ZAIZHI T WHERE 1 = 1 ");
			List<Object> params = new ArrayList<Object>();
			if(!"区本部".equals(orgName) && !StrUtil.isNullOrEmpty(orgName)) {
				sb.append(" AND T.FORGNAME like ? ");
				params.add("%"+orgName+"%");
			}
			sb.append(" order by T.FORGNAME,T.ORGNAME");
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, VAllStaffZaiZhi.class);
	}
	@Override
	public List<VSexCount> getSexList(VSexCount vSexCount) {
		String orgName = PermissionUtil.getManagerOrg();
		StringBuilder sb = new StringBuilder(
				" SELECT "
				+ " t.FORGNAME,t.ORGNAME,t.mencount,t.womencount"
				+ " FROM VIEW_SEX_COUNT T WHERE 1 = 1 ");
		List<Object> params = new ArrayList<Object>();
		if(!"区本部".equals(orgName) && !StrUtil.isNullOrEmpty(orgName)) {
			sb.append(" AND T.FORGNAME like ? ");
			params.add("%"+orgName+"%");
		}
		sb.append(" order by T.FORGNAME,T.ORGNAME ");
		return this.jdbcFindList(sb.toString(), params,VSexCount.class);
	}
	
}
